﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using NP.BPMReportPlatform.Entities.BPM_Business.CommonReportConfigs;
using NP.BPMReportPlatform.Reports.CommonReportConfigs.Dtos;
using NP.BPMReportPlatform.Reports.CXYXTHNRA.Dtos;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Application.Dtos;

namespace NP.BPMReportPlatform.Reports.CommonReportConfigs
{
    //[Authorize]
    [ApiController]
    [Route("api/CommonReportConfigs")]
    public class CommonReportConfigsController : BPMReportPlatformController
    {
        private readonly ICommonReportConfigsService _service;
        public CommonReportConfigsController(ICommonReportConfigsService service)
        {
            _service = service;
        }

        #region page

        /// <summary>
        /// 查询数据
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost("GetAllPageAsync")]
        public async Task<PagedResultDto<CommonReportPage>> GetAllPageAsync([FromBody] CommonReportPageInput input)
        {
            return await _service.GetAllPageAsync(input);
        }

        [HttpPost("AddOrUpdatePageAsync")]
        public async Task<IActionResult> AddOrUpdatePageAsync([FromBody] UpdateCommonReportPageInput input)
        {
            await _service.AddOrUpdatePage(input);
            return Ok();
        }

        [HttpPost("DeletePageAsync")]
        public async Task<IActionResult> DeletePageAsync([FromBody] DeleteCommonReportInput input)
        {
            await _service.DeletePage(input);
            return Ok();
        }

        [HttpPost("BindPageModule")]
        public async Task<IActionResult> BindPageModule([FromBody] BindPageModuleInput input)
        {
            await _service.BindPageModule(input);
            return Ok();
        }

        [HttpPost("DeletePageModule")]
        public async Task<IActionResult> DeletePageModule([FromBody] DeletePageModuleInput input)
        {
            await _service.DeletePageModule(input);
            return Ok();
        }

        #endregion

        #region module

        [HttpPost("GetAllModuleAsync")]
        public async Task<PagedResultDto<CommonReportModule>> GetAllModuleAsync([FromBody] CommonReportModuleInput input)
        {
            return await _service.GetAllModuleAsync(input);
        }

        [HttpPost("AddOrUpdateModuleAsync")]
        public async Task<IActionResult> AddOrUpdateModuleAsync([FromBody] UpdateCommonReportModuleInput input)
        {
            await _service.AddOrUpdateModule(input);
            return Ok();
        }

        [HttpPost("DeleteModuleAsync")]
        public async Task<IActionResult> DeleteModuleAsync([FromBody] DeleteCommonReportInput input)
        {
            await _service.DeleteModule(input);
            return Ok();
        }

        #endregion

        #region field

        [HttpPost("GetAllFieldAsync")]
        public async Task<PagedResultDto<CommonReportFieldConfig>> GetAllFieldAsync([FromBody] CommonReportFieldInput input)
        {
            return await _service.GetAllFieldAsync(input);
        }

        [HttpPost("AddOrUpdateFieldAsync")]
        public async Task<IActionResult> AddOrUpdateFieldAsync([FromBody] UpdateCommonReportFieldInput input)
        {
            await _service.AddOrUpdateField(input);
            return Ok();
        }

        [HttpPost("DeleteFieldAsync")]
        public async Task<IActionResult> DeleteFieldAsync([FromBody] DeleteCommonReportInput input)
        {
            await _service.DeleteField(input);
            return Ok();
        }

        [HttpPost("InitTable")]
        public async Task<List<CommonReportField>> InitTable([FromBody] CommonReportInitTableInput input)
        {
            return await _service.InitTable(input);
        }

        [HttpPost("BatchAddFields")]
        public async Task<IActionResult> BatchAddFields([FromBody] BatchAddCommonReportFieldInput input)
        {
            await _service.BatchAddFields(input);
            return Ok();
        }

        [HttpGet("GetCheckConfigs")]
        public async Task<List<CommonReportCheckConfigs>> GetCheckConfigs()
        {
            return await _service.GetCheckConfigs();
        }

        #endregion

        #region script

        /// <summary>
        /// 查询数据
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost("GetAllScriptAsync")]
        public async Task<PagedResultDto<CommonReportCustomScripts>> GetAllScriptAsync([FromBody] CommonReportCustomScriptsInput input)
        {
            return await _service.GetAllScriptAsync(input);
        }

        [HttpPost("AddOrUpdateScriptAsync")]
        public async Task<IActionResult> AddOrUpdateScriptAsync([FromBody] UpdateCommonReportCustomScriptsInput input)
        {
            await _service.AddOrUpdateScript(input);
            return Ok();
        }

        [HttpPost("DeleteScriptAsync")]
        public async Task<IActionResult> DeleteScriptAsync([FromBody] DeleteCommonReportInput input)
        {
            await _service.DeleteScript(input);
            return Ok();
        }

        #endregion
    }
}
